package org.azj.dbOperatorComponent;

// 代表列的属性
public class ColumnProperty implements IColumnProperty {

	private IBasicTableOperation belongingTable;
	private String columnName;
	private int dataType;
	private String typeName;
	private int columnSize;
	private boolean isNullable;
	private String defaultValue;
	private int indexOfTable;
	private boolean isAutoIncrement;
	
	public ColumnProperty(
			IBasicTableOperation belongingTable,
			String columnName,
			int dataType,
			String typeName,
			int columnSize,
			boolean isNullable,
			String defaultValue,
			int indexOfTable,
			boolean isAutoIncrement)
	{
		this.belongingTable = belongingTable;
		this.columnName = columnName;
		this.dataType = dataType;
		this.typeName = typeName;
		this.columnSize = columnSize;
		this.isNullable = isNullable;
		this.defaultValue = defaultValue;
		this.indexOfTable = indexOfTable;
		this.isAutoIncrement = isAutoIncrement;
	}
	
	@Override
	public IBasicTableOperation getBelongingTable() {
		return belongingTable;
	}

	@Override
	public String getColumnFullName() {
		return columnName;
	}
	
    @Override
    public String getColumnSimpleName() {
    	// columnName = schema.table.column 
    	String[] tmpStrings = columnName.split(".");
    	return tmpStrings[2];
    }

	@Override
	public int getDataType() {
		return dataType;
	}

	@Override
	public String getDataTypeName() {
		return typeName;
	}

	@Override
	public int getColumnSize() {
		return columnSize;
	}

	@Override
	public boolean isNullable() {
		return isNullable;
	}

	@Override
	public String defaultValue() {
		return defaultValue;
	}

	@Override
	public int indexOfTable() {
		return indexOfTable;
	}

	@Override
	public boolean isAutoIncrement() {
		return isAutoIncrement;
	}

}
